// MEMenuViewController.m
// TransitionFun
//
// Copyright (c) 2013, Michael Enriquez (http://enriquez.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "MEMenuViewController.h"
#import "PDSlideViewController.h"
#import "XBPushViewController.h"
#import "XBMenuTopView.h"

@interface MEMenuViewController ()
@property (nonatomic, strong) NSArray *menuItems;
@property (nonatomic, strong) UINavigationController *transitionsNavigationController;
@property (nonatomic, strong) XBMenuTopView *menuTopView;
@end

@implementation MEMenuViewController

- (void)viewDidLoad
{
     [super viewDidLoad];

     [self initView];




}

- (void)initView
{

     UIImageView *imgView = [[UIImageView alloc] init];
     imgView.frame = self.view.bounds;
     imgView.image = [UIImage imageNamed:@"menu-background"];
     [self.view addSubview:imgView];

     [self menuTopView];

     self.tableView = ({
          UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.menuTopView.frame), SCREEN_WIDTH, 350) style:UITableViewStylePlain];
          tableView.contentInset = UIEdgeInsetsMake(25, 0, 25, 0);
          tableView.delegate = self;
          tableView.dataSource = self;
          tableView.opaque = NO;
          tableView.backgroundColor = [UIColor clearColor];
          tableView.backgroundView = nil;
          tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
          tableView;
     });
     [self.view addSubview:self.tableView];


}

#pragma mark -
#pragma mark UITableView Delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [[PDSlideViewController slideVC] hideLeftVC];
     if (indexPath.row != 0) {
          [self.navigationController pushViewController:[[XBPushViewController alloc] init] animated:YES];
     }



}

#pragma mark -
#pragma mark UITableView Datasource

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
     return 54;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
     return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     static NSString *cellIdentifier = @"Cell";

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

     if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
          cell.backgroundColor = [UIColor clearColor];
          cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:21];
          cell.textLabel.textColor = [UIColor whiteColor];
          cell.textLabel.highlightedTextColor = [UIColor lightGrayColor];
          cell.selectedBackgroundView = [[UIView alloc] init];
     }
     cell.selectionStyle = UITableViewCellSeparatorStyleNone;
     NSArray *titles = @[@"Home", @"Calendar", @"Profile", @"Settings", @"Log Out"];
     NSArray *images = @[@"IconHome", @"IconCalendar", @"IconProfile", @"IconSettings", @"IconEmpty"];
     cell.textLabel.text = titles[indexPath.row];
     cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
     
     return cell;
}


- (XBMenuTopView *)menuTopView
{
     if (_menuTopView == nil) {
          _menuTopView = [[XBMenuTopView alloc] init];
          _menuTopView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 180);
          [self.view addSubview:_menuTopView];
     }
     return _menuTopView;
}

@end
